<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../common.inc" %>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="./css/style1.css" rel="stylesheet" type="text/css" />
<link href="./css/dtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="./js/dtree.js"></script>
<script type="text/javascript" language="javascript">
<!--
	function back(){
		var customerId = "<c:out value='${customerId}'/>";
		var sign = "<c:out value='${sign}'/>";
		if(sign != ""){
			window.location.href = "./customerManage.do?action=customerDetail&customerId="+customerId+"&sign="+sign;
		}else if(sign == "s1"){
			window.location.href = "./saleRecord.do?action=deptSaleRecord";
		}else{
			window.location.href = "./saleRecord.do";
		}
		window.location.target = "main";
	}

	function showHidden(id){
		var obj = document.getElementById(id);
		if(obj.style.display == "none"){
			document.getElementById(id).style.display = "block";
			document.getElementById("img"+id).src = "./images/nolines_minus.gif";
		}else{
			document.getElementById(id).style.display = "none";
			document.getElementById("img"+id).src = "./images/nolines_plus.gif";
		}
	}
-->
</script>
</head>
<body>
	<table class="table_title2">
		<tr>
			<td class="title_lab">查看联系记录</td>
		</tr>
		<tr>
			<td align="center" valign="bottom">
				<!-- 
				<button class="btn11" onclick="" hidefocus="true">新增销售日志**</button>&nbsp;&nbsp;
				 -->
				<button class="btn_back" onclick="back()" hidefocus="true">返回</button>
			</td>
		</tr>
		<tr><td height="2"></td></tr>
		<tr>
			<td>
				<table class="table_add">
					<tr>
						<td colspan="4" class="title_top">
							${customer.customerName}&nbsp;&nbsp;
							<c:if test="${customer.saleStatus == '1' || customer.saleStatus == '2' || customer.saleStatus == '21'}">
								<font color="red">(商机挂起)</font>
							</c:if>
						</td>
					</tr>
					<tr>
						<td class="title">建档日期：</td>
						<td><fmt:formatDate value="${customer.createDate}" pattern="yyyy-MM-dd"/>&nbsp;</td>
						<td class="title">建档人：</td>
						<td>${customer.createPerson}&nbsp;</td>
					</tr>
					<tr>
						<td class="title">客户来源：</td>
						<td>
							<c:choose>
								<c:when test="${customer.customerSourceId == 1}"><fmt:message key='customer.select.self'/></c:when>
								<c:when test="${customer.customerSourceId == 2}"><fmt:message key='customer.select.companySet'/></c:when>
								<c:when test="${customer.customerSourceId == 3}"><fmt:message key='customer.select.market'/></c:when>
								<c:otherwise><fmt:message key='customer.select.other'/></c:otherwise>
							</c:choose>&nbsp;
						</td>
						<td class="title">历史签约金额：</td>
						<td>￥ <fmt:formatNumber value="${customer.historyContractCost}" pattern="###,###,###,###"/>元&nbsp;</td>
					</tr>
					<tr>
						<td class="title">当前销售阶段：</td>
						<td>
						<c:choose>
							<c:when test="${customer.saleStatus == '1' || customer.saleStatus == '2' || customer.saleStatus == '21'}">
								<font color="red">挂起</font>
							</c:when>
							<c:otherwise>${customer.saleStage}</c:otherwise>
						</c:choose>
							&nbsp;
						</td>
						<td class="title">应收账款余额：</td>
						<td>￥ <fmt:formatNumber value="${customer.receivable}" pattern="###,###,###,###"/>元&nbsp;</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr><td height="2"></td></tr>
		<tr>
			<td valign="top">
				<table class="table_border">
					<tr>
						<td width="180" valign="top">
							<div class="org_tree_title">当前商机联系日志</div>
							<div class="org_tree">
								<script type="text/javascript">
								<!--
									d1 = new dTree('d1');
								<c:choose>
									<c:when test='${customer.saleStatus == 1 || customer.saleStatus == 2 || customer.saleStatus == 21}'>
										d1.add('0','-1',"商机挂起",'','','','','','true');
									</c:when>
									<c:otherwise>d1.add('0','-1',"新商机跟进",'','','','','','true');</c:otherwise>
								</c:choose>
								//-->
								</script>
								<c:forEach var="saleStage" items="${saleStages}">
								<script type="text/javascript">
								<!--
									d1.add('${saleStage.stageCode}','0','${saleStage.stageName}','','','','','','true');
								//-->
								</script>
									<c:forEach var="saleRecord" items="${saleRecords}">
									<c:if test="${saleRecord.saleStageId == saleStage.stageCode}">
									<script type="text/javascript">
									<!--
										d1.add('${saleRecord.id}+999999','${saleRecord.saleStageId}',"<fmt:formatDate value='${saleRecord.contactDate}' pattern='yyyy-MM-dd'/>"
											,'./saleRecord.do?action=viewSaleRecordInfo&id=${saleRecord.id}&customerId=${saleRecord.customerId}&sign=${sign}','','vSaleRecord','','','true');
									//-->
									</script>
									</c:if>
									</c:forEach>
								</c:forEach>
								<script type="text/javascript">
								<!--
									document.write(d1);					
								//-->
								</script><br>
							</div>
							<c:if test="${customer.saleStatus == '1' || customer.saleStatus == '2' || customer.saleStatus == '21'}">
								<div class="org_tree">
									<script type="text/javascript">
									<!--
										d11 = new dTree('d11');
									//-->
									</script>
									<c:choose>
										<c:when test="${customer.saleStatus == '2'}">
											<script type="text/javascript">
											<!--
												d11.add('0','-1','挂起：公海超期','','','','','','true');
											//-->
											</script>
										</c:when>
										<c:when test="${customer.saleStatus == '21'}">
											<script type="text/javascript">
											<!--
												d11.add('0','-1','挂起：丢弃客户','','','','','','true');
											//-->
											</script>
										</c:when>
										<c:otherwise>
											<c:forEach var="saleRecord" items="${hangupSaleRecords}">
											<script type="text/javascript">
											<!--
												d11.add('0','-1','挂起：<fmt:formatDate value='${saleRecord.createDate}' pattern='yyyy-MM-dd'/>'
														,'./saleRecord.do?action=viewSaleRecordInfo&id=${saleRecord.id}&customerId=${saleRecord.customerId}&sign=${sign}','','vSaleRecord','','','true');
											//-->
											</script>
											</c:forEach>
										</c:otherwise>
									</c:choose>
									<script type="text/javascript">
									<!--
										document.write(d11);					
									//-->
									</script><br>
								</div>
							</c:if>
							<div class="org_tree_title" onclick="showHidden('1')">
								<img id="img1" src="./images/nolines_minus.gif">历史商机联系记录
							</div>
							<div id="1" style="display: block;" class="org_tree">
								<c:forEach var="hisRootSaleRecord" items="${hisRootSaleRecords}" varStatus="hs">
								<script type="text/javascript">
								<!--
									dd${hs.count} = new dTree('dd${hs.count}');
									dd${hs.count}.add('0','-1',"关闭：<fmt:formatDate value='${hisRootSaleRecord.contactDate}' pattern='yyyy-MM-dd'/>",'','','','','','true');
								//-->
								</script>
								<c:forEach var="saleStage" items="${saleStages}">
								<script type="text/javascript">
								<!--
									dd${hs.count}.add('${saleStage.stageCode}','0','${saleStage.stageName}','','','','','','true');
								//-->
								</script>
									<c:forEach var="saleRecord" items="${hisSaleRecords}">
									<c:if test="${saleRecord.saleStageId == saleStage.stageCode && saleRecord.parentId == hisRootSaleRecord.parentId}">
									<script type="text/javascript">
									<!--
										dd${hs.count}.add('${saleRecord.id}+999999','${saleRecord.saleStageId}',"<fmt:formatDate value='${saleRecord.contactDate}' pattern='yyyy-MM-dd'/>"
											,'./saleRecord.do?action=viewSaleRecordInfo&id=${saleRecord.id}&customerId=${saleRecord.customerId}&sign=${sign}','','vSaleRecord','','','true');
									//-->
									</script>
									</c:if>
									</c:forEach>
								</c:forEach>
								<script type="text/javascript">
								<!--
									document.write(dd${hs.count});					
								//-->
								</script><br>
								</c:forEach>
							</div>
							<div class="org_tree_title" onclick="showHidden('2')">
								<img id="img2" src="./images/nolines_plus.gif">老客户日常关怀记录
							</div>
							<div id="2" style="display: none;" class="org_tree">
								<script type="text/javascript">
								<!--
									d3 = new dTree('d3');
									d3.add('0','-1',"老客户日常关怀",'','','','','','true');
								//-->
								</script>
								<c:forEach var="saleRecord" items="${careSaleRecords}">
									<script type="text/javascript">
									<!--
										d3.add('${saleRecord.id}+999999','0',"<fmt:formatDate value='${saleRecord.contactDate}' pattern='yyyy-MM-dd'/>"
											,'./saleRecord.do?action=viewSaleRecordInfo&id=${saleRecord.id}&customerId=${saleRecord.customerId}&sign=${sign}','','vSaleRecord','','','true');
									//-->
									</script>
								</c:forEach>
								<script type="text/javascript">
								<!--
									document.write(d3);					
								//-->
								</script><br>
							</div>
						</td>
						<td width="1"></td>
						<td valign="top">
							<iframe src="./saleRecord.do?action=viewSaleRecordInfo&customerId=${customerId}&sign=${sign}" id="vSaleRecord" name="vSaleRecord" frameborder="2" scrolling="no" width="100%" 
								onload="this.height=vSaleRecord.document.body.scrollHeight;"></iframe>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
	<input id="customerId" name="customerId" type="hidden" value="${customerId}"/>
</body>
</html>